#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <climits>
#define int long long 
#define x first 
#define y second 
using namespace std ;

constexpr int N = 1e6 + 5, V = 2e5 + 5;

int T, n;
int a[N], b[V];

void solve() {
	std::cin >> n; std::set<int> s;
	for (int i = 1; i <= n; i++) std::cin >> a[i], s.insert(a[i]), b[a[i]]++;
	
	int ans = (1 << 30);
	for (int i = 1; i <= V; i++) {
		int cur = *s.begin(), cnt = 1;
		while (true) {
			auto pos = s.upper_bound(cur + i - 1);
			if (pos == s.end()) break;
			cnt++; cur = *pos;
		}
		ans = std::min(ans, cnt + i - 1);
	}
	std::cout << ans << "\n";
}

signed main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	T = 1;
	while (T--) solve();

	return 0;
}